from tkinter import *
from tkinter import messagebox

root = Tk()
root.title('my firest')

root.geometry('500x300+100+200')
lable1 = Label(root,text='用户名',font=('red',10))
lable1.pack()

v1 = StringVar()
entry1 = Entry(root,textvariable=v1)
entry1.pack()
# 初始值
v1.set('admin')
# 得到输入框中的值
print(entry1.get())
print(v1.get())

# 密码框
lable2 = Label(root,text='密码',font=('red',10))
lable2.pack()
v2 = StringVar()
entry2 = Entry(root,textvariable=v2)
entry2.pack()

def login():
    username = v1.get()
    passwd = v2.get()
    messagebox.showinfo('登录','恭喜登录成功,请注意保存你的用户名%s和密码%s'%(username,passwd))

# 登录按键
b1 = Button(root,text='登录',command=login)
b1.pack()

root.mainloop()
